package com.luobd.bpm.dto;

import com.luobd.bpm.business.process.entity.CoreProcessDef;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.activiti.engine.repository.ProcessDefinition;

import java.time.LocalDateTime;

@Data
public class ProcessDefinitionDTO {


    @ApiModelProperty(value = "流程定义id")
    private String id;


    @ApiModelProperty(value = "流程定义id")
    private String processDefinitionId;

    @ApiModelProperty(value = "流程定义分类")
    private String category;


    @ApiModelProperty(value = "流程定义状态")
    private String status;


    @ApiModelProperty(value = "流程定义名称")
    private String name;


    @ApiModelProperty(value = "流程定义版本")
    private Integer version;


    @ApiModelProperty(value = "流程定义key")
    private String key;


    @ApiModelProperty(value = "流程定义描述")
    private String description;


    @ApiModelProperty(value = "流程定义部署id")
    private String deploymentId;


    @ApiModelProperty(value = "流程定义资源名称")
    private String resourceName;


    @ApiModelProperty(value = "流程定义是否挂起")
    private Boolean suspended;


    @ApiModelProperty(value = "流程定义是否启动表单")
    private boolean hasStartFormKey;



    @ApiModelProperty(value = "流程定义创建时间")
    private LocalDateTime createTime;


    public ProcessDefinitionDTO() {
    }


    public ProcessDefinitionDTO(CoreProcessDef definition) {
        this.id = String.valueOf(definition.getId());
        this.processDefinitionId = definition.getProcessDefinitionId();
        this.category = definition.getCategory();
        this.name = definition.getName();
        this.version = definition.getVersion();
        this.key = definition.getProcessKey();
        this.description = definition.getRemark();
        this.status = CoreProcessDef.ProcessStatus.getByCode(definition.getStatus()).getDesc();
        this.createTime = definition.getCreateTime();
    }

    public ProcessDefinitionDTO(ProcessDefinition definition) {
        this.id = definition.getId();
        this.category = definition.getCategory();
        this.name = definition.getName();
        this.version = definition.getVersion();
        this.key = definition.getKey();
        this.description = definition.getDescription();
        this.deploymentId = definition.getDeploymentId();
        this.resourceName = definition.getResourceName();
        this.suspended = definition.isSuspended();
        this.hasStartFormKey = definition.hasStartFormKey();

    }


}
